/***************************************************************************
 创建者：       hualei
 开始时间：    2018.09.10
 copyright:(C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************/
#include "odometryinstructionview.h"
#include "ui_odometryinstructionview.h"
#include "../../programView/programview.h"

OdometryInstructionView::OdometryInstructionView(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::OdometryInstructionView)
{
    ui->setupUi(this);
    initialDisplayStyle(styleId);
}

void OdometryInstructionView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->forward_Btn->setGeometry(10,350,70,40);
        ui->save_Btn->setGeometry(360,350,70,40);
        break;
    default:
        break;
    }
}

void OdometryInstructionView::getInput()
{
    posX = ui->ODOM_PosX_Edit->text().toDouble();
    posY = ui->ODOM_PosY_Edit->text().toDouble();
    posR = ui->ODOM_PosR_Edit->text().toDouble();
    noteStr = ui->note_lineEdit->text();

}

void OdometryInstructionView::updataView()
{
    ui->ODOM_PosX_Edit->setText(QString::number(posX, 10, 3));
    ui->ODOM_PosY_Edit->setText(QString::number(posY, 10, 3));
    ui->ODOM_PosR_Edit->setText(QString::number(posR, 10, 3));
    ui->note_lineEdit->setText(noteStr);

}

void OdometryInstructionView::changeLanguage(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/OdometryInstructionView.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }
    ui->retranslateUi(this);

}


void OdometryInstructionView::on_Reset_Odometry_Btn_clicked()
{
    getInput();

}

void OdometryInstructionView::on_save_Btn_clicked()
{
    getInput();
    emit finishEditInstruction();
    emit saveInstructionSignal(instructionOut);
}

void OdometryInstructionView::on_forward_Btn_clicked()
{
    this->close();
    programView->instructionListFlag = 0;
    programView->editInstructionViewShowOrHide();

}

void OdometryInstructionView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->clear();
    emit cleanNoteSignal();
}
